/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package merlion.crm.slcm.entity;

import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import merlion.mrp.ppm.entity.Product;

/**
 *
 * @author Yuwei
 */
@Entity
@NamedQuery(name = "getAllOrderDiscountGroup", query = "SELECT o from OrderDiscountGroup o")
public class OrderDiscountGroup implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    
    // Given Item Line, output object with discount given
    //private String orderDiscountGroup;
    @ManyToOne(targetEntity=Product.class, cascade={CascadeType.ALL}, fetch=FetchType.EAGER)
    private Product product;
    private Long quantity;
    private Double orderDiscount;
    
    public OrderDiscountGroup(){
        product = new Product(0);
        //orderDiscountGroup = "";
        quantity = (long) 0;
        orderDiscount = (double)0;
    }
    
    public void create(Product product, Long quantity, Double orderDiscount){
        //this.orderDiscountGroup = groupName;
        this.product = product;
        this.quantity = quantity;
        this.orderDiscount = orderDiscount;
    }
    
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
    

    public Product getProduct(){
        return product;
    }
    
    public void setProduct(Product pd){
        this.product = pd;
    }
    
    public Long getQuantity(){
        return quantity;
    }
    
    public void setQuantity(Long quantity){
        this.quantity = quantity;
    }

    public Double getOrderDiscount() {
        return orderDiscount;
    }

    public void setOrderDiscount(Double orderDiscount) {
        this.orderDiscount = orderDiscount;
    }


    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof OrderDiscountGroup)) {
            return false;
        }
        OrderDiscountGroup other = (OrderDiscountGroup) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "merlion.crm.slcm.entity.OrderDiscountGroup[ id=" + id + " ]";
    }
}
